#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    vector<vector<int>> subsets(vector<int>& nums) {
        int n = nums.size();
        vector<vector<int>> ret;

        for (int i = 0; i < 1 << n; i++)
        {
            vector<int> tmp;
            for (int j = 0; j < n; j++)
            {
                if (i >> j & 1)
                {
                    tmp.push_back(nums[j]);
                }
            }
            ret.push_back(tmp);
        }
        return ret;
    }
};


int main() {
    Solution sol;
    vector<int> nums = { 1, 2, 3 };
    vector<vector<int>> result = sol.subsets(nums);
    for (const auto& sub : result) {
        for (int num : sub) {
            cout << num << " ";
        }
        cout << endl;
    }
    return 0;
}